<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script>
      /*点击超链接或*/
      window.onload = function(){
        //1.获取图片对象,来加载单击事件
        var img = document.getElementById("checkCode");
        // 绑定单击事件
        img.onclick = function(){
          //加时间
          var date = new Date().getTime();
          img.src = "/ResponseCodeServlet?"+date;
          //后面的?date是因为浏览器读取的是缓存,所以使用?date来让浏览器重新加载

          var a = document.getElementById("change");
          a.onclick = function(){
            //加时间
            var date = new Date().getTime();
            img.src = "/ResponseCodeServlet?"+date;
          }
        }
      }
  </script>
</head>
<body>
  <img id="checkCode" src="/ResponseCodeServlet" />
  <a id="change" href="#">看不清换一张</a>
</body>
</html>